package com.example.tangjiangxu.kotlintest;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

/**
 * Created by tangjiangxu on 5/31/17.
 */

public class TestActivity extends Activity {
    private static final String TAG = "TestActivity";
    private Button bnClick;


    private String str;

    private void print() {
        if (str != null) {
            str.toString();
        }
    }


    private void testLamda() {

        //匿名内部类方式
        bnClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(TestActivity.this, "Button  Click!", Toast.LENGTH_LONG).show();
            }
        });

        //lambda表达式
        //bnClick.setOnClickListener(view-> Toast.makeText(TestActivity.this, "Button  Click!", Toast.LENGTH_LONG).show());

    }

    /**
     * 得到字符串的长度
     * @param obj
     * @return
     */
    private int getStringLenght(Object obj) {
        int length = 0;
        if (obj instanceof String) {
            length = ((String) obj).length();
        }
        return length;
    }

    /**
     * java调用Kotlin代码
     */
    private void javaCallKotlin() {
        Customer customer = new Customer("Josan", "2222@qq.com");
        customer.setName("Tang");
    }

}
